//
//  TPolicyTableViewCell.m
//  Village
//
//  Created by longrise on 2017/9/13.
//  Copyright © 2017年 程虎. All rights reserved.
//

#import "TPolicyTableViewCell.h"
#import "UITableViewCell+FSAutoCountHeight.h"



@implementation TPolicyTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.contentLab = [[UILabel alloc]init];
        self.contentLab.font = [UIFont systemFontOfSize:16*kScreenScaleX];
        [self.contentLab sizeToFit];
        self.contentLab.numberOfLines = 0;
        [self.contentView addSubview:self.contentLab];
        
        self.contentImageView = [[UIImageView alloc]init];
        //        self.contentImageView.frame = CGRectMake(15, 15, 85, 64);
        [self.contentImageView sizeToFit];
        self.contentImageView.layer.cornerRadius=5.0f;// 将图层的边框设置为圆角
        self.contentImageView.layer.masksToBounds=YES;// 隐藏边界
        [self.contentView addSubview:self.contentImageView];
        
        self.nameLab = [[UILabel alloc]init];
        self.nameLab.font = [UIFont systemFontOfSize:11*kScreenScaleX];
        [self.nameLab sizeToFit];
        self.nameLab.textColor = [UIColor colorWithRed:217/255.0 green:215/255.0 blue:224/255.0 alpha:1];
        [self.contentView addSubview:self.nameLab];
        {
        [self.contentImageView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.contentView.mas_top).with.offset(15*kScreenScaleY);
                make.left.equalTo(self.contentView.mas_left).with.offset(0);
                make.width.mas_equalTo(0);
                make.height.mas_equalTo(0);
            }];
        [self.contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.contentView.mas_top).with.offset(19*kScreenScaleY);
                make.left.equalTo(self.contentImageView.mas_right).with.offset(15*kScreenScaleX);
                make.right.lessThanOrEqualTo(self.contentView.mas_right).with.offset(-10*kScreenScaleX);
            }];
        [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.contentLab.mas_bottom).with.offset(10*kScreenScaleY);
                make.left.mas_equalTo(self.contentLab);
            }];
        }
    }
    self.FS_cellBottomView = self.nameLab;//尽量传入底视图，不传也不会报错
    return self;
}

- (void)setPolicy:(PolicyModel *)policy
{
    
    self.contentLab.textColor =  [Util colorWithHexString:@"333333"];
    self.nameLab.textColor =   [Util colorWithHexString:@"bbbbbb"];
    self.contentLab.text = policy.title;
    
    NSString *str = policy.publishtime;
    str = [str substringToIndex:10];//截取掉下标7之后的字符串
   
    NSString *red = policy.readnum;
    if (policy.readnum == nil ){
       red = @"0";
    }else{
        
    }
    NSString *stry = [NSString stringWithFormat:@"%@·%@   %@阅读",policy.creator,str,red];
  
    self.nameLab.text = stry;
}

//- (void)setEntity:(FSEntity *)entity
//{
//        self.contentLab.textColor =  [Util colorWithHexString:@"333333"];
//        self.nameLab.textColor =   [Util colorWithHexString:@"bbbbbb"];
//
//    NSLog(@"++++++++++++++++++++++++++++++++++++%@",entity.imageName);
//
//    NSString *stry = [NSString stringWithFormat:@"%@·1小时前   567阅读",entity.username];
//
//    self.contentLab.text = entity.title;
//    self.contentImageView.image = [UIImage imageNamed:entity.imageName];
//    self.nameLab.text = stry;
//}

@end
